
require(["config"], function(config) {
	require(["jquery","com","gv","move","swp"],function(jq,com,gv,move,swp) {
		var total = 12*24*3600;
		setInterval(function(){
			var days = Math.floor(total/(24*3600));
			var one = total-(days*24*3600);
			var hours = Math.floor(one/3600);
			hours=hours<10?"0"+hours:hours;
			var mins = Math.floor((one-hours*3600)/60);
			mins=mins<10?"0"+mins:mins;
			var secs = Math.round(one-hours*3600-mins*60);
			secs=secs<10?"0"+secs:secs;
			var tm0 = document.getElementById("tm0");
			var tm1 = document.getElementById("tm1");
			var tm2 = document.getElementById("tm2");
			var tm3 = document.getElementById("tm3");
			tm0.innerHTML = days;
			tm1.innerHTML = hours;
			tm2.innerHTML = mins;
			tm3.innerHTML = secs;
			total--;
			if(total<=0){
				total=24*3600;
			}
		},1000)
		
		
		jq(function(){
			var $sImg = $("#smallImg");
			var $sc = $("#smallCursor");
			var $bImg1 = $(".bigImg1");
			var $bc = $("#bigCursor");
			//小放大镜的宽度/小图的宽度 === 大放大镜的宽度/大图的宽度
			$sImg.hover(function(){
				$bc.show();
				var _width = Math.round($bc.width()*$sImg.width()/(2*$bImg1.width()));
				var scale = Math.round(2*$bImg1.width()/$sImg.width());
				$sc.width(_width).height(_width).show();
				$sImg.mousemove(function(evt){
					//计算鼠标在小图中的坐标
					var mousex = evt.pageX - $(this).offset().left;
					var mousey = evt.pageY - $(this).offset().top;
					//让小放大镜跟随鼠标移动
					$sc.css({
						left: Math.min($sImg.width()-_width, Math.max(0,mousex-_width/2)), 
						top: Math.min($sImg.height()-_width, Math.max(0,mousey-_width/2))
					});
					
					//大图片移动
					//console.log($sc.position().left*scale)
					$bImg1.css({
						left: -$sc.position().left*scale+193,
						top: -$sc.position().top*scale+188
					})
				});
			},function(){
				$sc.hide();
				$bc.hide();
			})
			
			$("#ul li:nth(0)").hover(function(){
				$("#ul li:nth(0)").css({"border":"1px solid red"}).siblings().css({"border":"0"})
				$sImg.find("img").attr({"src":"images/images/SP3030_303001516442_0_10007.jpg"})
				$bImg1.attr({"src":"images/images/SP3030_303001516442_0_10007.jpg"})
			})
			$("#ul li:nth(1)").hover(function(){
				$("#ul li:nth(1)").css({"border":"1px solid red"}).siblings().css({"border":"0"})
				$sImg.find("img").attr({"src":"images/images/SP3030_303001516442_1_10007.jpg"})
				$bImg1.attr({"src":"images/images/SP3030_303001516442_1_10007.jpg"})
			})
			$("#ul li:nth(2)").hover(function(){
				$("#ul li:nth(2)").css({"border":"1px solid red"}).siblings().css({"border":"0"})
				$sImg.find("img").attr({"src":"images/images/SP3030_303001516442_2_10007.jpg"})
				$bImg1.attr({"src":"images/images/SP3030_303001516442_2_10007.jpg"})
			})
			$("#ul li:nth(3)").hover(function(){
				$("#ul li:nth(3)").css({"border":"1px solid red"}).siblings().css({"border":"0"})
				$sImg.find("img").attr({"src":"images/images/SP3030_303001516442_3_10007.jpg"})
				$bImg1.attr({"src":"images/images/SP3030_303001516442_3_10007.jpg"})
			})
		});
		
		
		jq(function(){
			var one = $(".num1 #sub").val()-1+1;
			$(".num2 .butt1").click(function(){
				one += 1;
				$(".num1 #sub").val(one);
				$(".num2 .num3").hide();
				
			})
			$(".num2 .but1").click(function(){
				one -= 1;
				$(".num1 #sub").val(one);
				if(one==1){
					$(".num2 .num3").show();
				}
			})
		})
		
		
		onload = function(){
			var dianji = document.getElementById("get");
			var i=1;
			/*dianji.onclick = function(){
				i++;
				if(i>5){
					alert("你已买了五件了，还没够啊!");
					return;
				}
				var two = document.createElement("img");
				two.src = "images/images/SP3030_303001516442_0_10007.jpg";
				document.body.appendChild(two);
				two.style.position="absolute";
				two.style.left="20px";
				two.style.top = "500px";
				animate(two,{left:1250,top:420,height:0},{
					callback:function(){
						two.remove();
					}
				},50);
			}*/
			
			var one = document.getElementById("sub");
			dianji.onclick = function(){
				var i=1;
				var time = setInterval(function(){
					var two = document.createElement("img");
					two.src = "images/images/SP3030_303001516442_0_10007.jpg";
					document.body.appendChild(two);
					two.style.position="absolute";
					two.style.left="20px";
					two.style.top = "500px";
					animate(two,{left:1250,top:420,height:0},{
						callback:function(){
							two.remove();
						}
					},500);
					i++;
					if(i>(one.value-1+1)){
						clearInterval(time);
					}
				},1000)
			}
		}
		
		jq(function(){
			$(".mai span").mouseover(function(){
				$(".mai div").show();
				setTimeout(function(){
					$(".mai div").hide();
				},3000)
			})
		})
		
		jq(function(){
			$("#gouwuche .xingxi").hover(function(){
				$("#gouwuche .xingxi p").animate({right:-4},500);
			})
			$("#gouwuche .xingxi").mouseout(function(){
				$("#gouwuche .xingxi p").animate({right:-66},500);
			})
			$("#gouwuche .sale").hover(function(){
				$(this).css({"background":"red"})
			})
			$("#gouwuche .sale").mouseout(function(){
				$(this).css({"background":"#2F3A47"})
			})	
		})
		
		
		jq(function(){
			$(document).scroll(function(){
				if($(document).scrollTop()>720){
					$(".xuanfu").show();
				}else{
					$(".xuanfu").hide();
				}
			})
			
			$(".num1").click(function(){
				$(".num1").css({"border-top":"1px solid red"}).siblings().css({"border":""});
				$(".num1 a").css({"color":"red"}).siblings().css({"color":"black"});
				$("#jieshao").show().siblings().hide();
			})
			$(".num2").click(function(){
				$(".num2").css({"border-top":"1px solid red"}).siblings().css({"border":""});
				$(".num2 a").css({"color":"red"}).siblings().css({"color":"black"});
				$(".canshu").show().siblings().hide();
			})
			$(".num3").click(function(){
				$(".num3").css({"border-top":"1px solid red"}).siblings().css({"border":""});
				$(".num3 a").css({"color":"red"}).siblings().css({"color":"black"});
				$(".ping").show().siblings().hide();
			})
			$(".num4").click(function(){
				$(".num4").css({"border-top":"1px solid red"}).siblings().css({"border":""});
				$(".num4 a").css({"color":"red"}).siblings().css({"color":"black"});
				$(".ping").show().siblings().hide();
			})
		})
		
		 
		
		
		
	})
})

